<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-09 10:07:06
 * @LastEditTime: 2019-10-17 17:48:32
 * @LastEditors: Please set LastEditors
 -->
<template>
  <div class="home">
    <div class="box">
      <div class="ball wow bounceInLeft" data-wow-delay="0.4s" @click="aa">
        <img :src="aaa?require('../assets/strive.png'):require('../assets/striveno.png')" alt>
        <p class="one_p">努力</p>
        <p class="two_p">STRIVE</p>
      </div>
      <div class="ball wow bounceInRight" data-wow-delay="0.6s" @click="bb">
        <img :src="bbb?require('../assets/Modest.png'):require('../assets/Modestno.png')" alt>
        <p class="one_p">谦虚</p>
        <p class="two_p">MODEST</p>
      </div>
      <div class="ball wow bounceInLeft" data-wow-delay="0.8s" @click="cc">
        <img :src="ccc?require('../assets/introspection.png'):require('../assets/introspectionno.png')" alt>
        <p class="one_p">反省</p>
        <p class="two_p">INTROSPECTION</p>
      </div>
      <div class="ball wow bounceInRight" data-wow-delay="1s" @click="dd">
        <img :src="ddd?require('../assets/thank.png'):require('../assets/thankno.png')" alt>
        <p class="one_p">感谢</p>
        <p class="two_p">THANK</p>
      </div>
      <div class="ball wow bounceInLeft" data-wow-delay="1.2s" @click="ee">
        <img :src="eee?require('../assets/altruism.png'):require('../assets/altruismno.png')" alt>
        <p class="one_p">利他</p>
        <p class="two_p">ALTRUISM</p>
      </div>
      <div class="ball wow bounceInRight" data-wow-delay="1.4s" @click="ff">
        <img :src="fff?require('../assets/optimistic.png'):require('../assets/optimisticno.png')" alt>
        <p class="one_p">乐观</p>
        <p class="two_p">OPTIMISTIC</p>
      </div>
    </div>
    <div class="footer">
      <div class="out_1">
        <div class="in_1">
          <img src="../assets/home_left_red.png">
          <p style="color:#EB2616;">首页</p>
        </div>
      </div>
      <div class="out_1" @click="mine">
        <div class="in_1">
          <img src="../assets/home_right.png">
          <p style="color:#A9A9A9;">我的</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {check_login,get_rel_list} from '../api/api.js'
import { Toast } from "mint-ui";
export default {
  name: "home",
  data() {
    return {
      user_id:'',
      aaa:'',
      bbb:'',
      ccc:'',
      ddd:'',
      eee:'',
      fff:'',
      date:''
    };
  },
  mounted() {
    if (sessionStorage.getItem("mobile") != null) {
      this.mobile = JSON.parse(sessionStorage.getItem("mobile"));
    }
    check_login({
      data: {
        mobile: this.mobile
      }
    }).then(res => {
      if (res.data.code == 11001) {
      } else if (res.data.code == 11000) {
        this.$toast("未登录，请重新登录");
        this.$router.push("/");
      }
    });
    sessionStorage.setItem("text_title", JSON.stringify(''));
    if(sessionStorage.getItem("xuan") != undefined){
      sessionStorage.setItem("xuan", JSON.stringify(''));
    }
    if(sessionStorage.getItem("xuan_two") != undefined){
      sessionStorage.setItem("xuan_two", JSON.stringify(''));
    }
    if(sessionStorage.getItem("xuan_three") != undefined){
      sessionStorage.setItem("xuan_three", JSON.stringify(''));
    }
    if(sessionStorage.getItem("xuan_four") != undefined){
      sessionStorage.setItem("xuan_four", JSON.stringify(''));
    }
  },
  created(){
    if (sessionStorage.getItem("data_mobal") != null) {
      this.user_id = JSON.parse(
        JSON.parse(sessionStorage.getItem("data_mobal"))
      ).user_id;
    }
    get_rel_list({data:{
      user_id:this.user_id
    }}).then(res=>{
      console.log(res)
      if(res.data.code==10091){
        this.date=JSON.parse(res.data.body.data)
        console.log(this.date)
        if(this.date.ent_flag==0){
          this.aaa=false
          this.bbb=false
          this.ccc=false
          this.ddd=false
          this.eee=false
          this.fff=false
        }
        else{
          sessionStorage.setItem("mlbb_xinxi", JSON.stringify(this.date.staff_info));
          // this.aaa=true
          // this.bbb=true
          // this.ccc=true
          // this.ddd=true
          // this.eee=true
          // this.fff=true
          this.aaa=true
          this.bbb=true
          this.ccc=false
          this.ddd=true
          this.eee=false
          this.fff=false
          // let list=this.date.rel_list
          // // console.log(list)
          // for(let i=0;i<list.length;i++){
          //   if(list[i].module_id==1){
          //     this.aaa=true
          //   }
          //   if(list[i].module_id==2){
          //     this.bbb=true
          //   }
          //   if(list[i].module_id==3){
          //     this.ccc=true
          //   }
          //   if(list[i].module_id==4){
          //     this.ddd=true
          //   }
          //   if(list[i].module_id==5){
          //     this.eee=true
          //   }
          //   if(list[i].module_id==6){
          //     this.fff=true
          //   }

          // }
        }
      }else if(res.data.code==10092){
        // 程序错误
      }
    })
  },
  watch: {},
  methods: {
    aa() {
      if(this.date.ent_flag==0){
        Toast('您还未与企业认证')
      }else if(this.aaa){
        Toast('正在努力开发中')
      }else if(this.aaa==false){
        Toast('正在努力开发中')
      }
    },
    bb() {
      if(this.date.ent_flag==0){
        Toast('您还未与企业认证')
      }else if(this.bbb){
        this.$router.push('/sale')
      }else if(this.bbb==false){
        Toast('正在努力开发中')
      }
    },
    cc() {
      if(this.date.ent_flag==0){
        Toast('您还未与企业认证')
      }else if(this.ccc){
        Toast('正在努力开发中')
      }else if(this.ccc==false){
        Toast('正在努力开发中')
      }
    },
    dd() {
      if(this.date.ent_flag==0){
        Toast('您还未与企业认证')
      }else if(this.ddd){
        Toast('正在努力开发中')
      }else if(this.ddd==false){
        Toast('正在努力开发中')
      }
    },
    ee() {
      if(this.date.ent_flag==0){
        Toast('您还未与企业认证')
      }else if(this.eee){
        Toast('正在努力开发中')
      }else if(this.eee==false){
        Toast('正在努力开发中')
      }
    },
    ff() {
      if(this.date.ent_flag==0){
        Toast('您还未与企业认证')
      }else if(this.fff){
        Toast('正在努力开发中')
      }else if(this.fff==false){
        Toast('正在努力开发中')
      }
    },
    mine(){
      this.$router.push('/mine')
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.home {
  background: url("../assets/background_2.png") 50% 0 repeat-y fixed;
  height: 100vh;
  background-size: 100%;
  .box {
    width: 96%;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    padding-top: 0.63rem;
    .ball {
      text-align: center;
      margin: 0 0.1rem 0.22rem 0.5rem;
      animation-duration: 2s;
      img{
        height:0.97rem;
        width:0.97rem;
      }
      .one_p{
        color:#131F2D;
        font-size: 0.14rem;
      }
      .two_p{
        color:#DBAD80;
        font-size: 0.1rem;
      }
    }
  }
  .footer {
    position: fixed;
    bottom: 0;
    height: 0.49rem;
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    background: -webkit-linear-gradient(left, #F3F7F5, #EAEFED);
    background: -o-linear-gradient(right, #F3F7F5, #EAEFED);
    background: -moz-linear-gradient(right, #F3F7F5, #EAEFED);
    background: linear-gradient(to right, #F3F7F5, #EAEFED);
    .out_1 {
      width: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      .in_1 {
        img {
          margin: 0 auto;
          height: 0.24rem;
          width: 0.24rem;
        }
        p {
          margin: 0 auto;
          font-size: 0.1rem;
          font-weight: 500;
        }
      }
    }
  }
}
</style>
